#include <iostream> 
using namespace std;

class Product{
	public:
		Product(){
			cout<<"Product.Des"<<endl;
		}
		virtual void Operation()=0;
		virtual ~Product(){
			cout<<"Product.Des"<<endl;
		}
};

class Factory {
	private:
		Product *p;
	public:
		Factory(Product *_p){
			p=_p;		
		}
		void Operation(){
			p->Operation();
		}
		~Factory(){
			delete p;
		}
};

class ProA:public Product{
	public:
		void Operation() {
			cout<<"ProA Done"<<endl;
		}
		~ProA() {
			cout <<"ProA.Des"<<endl;
		}
};

class ProB:public Product{
	public:
		void Operation() {
			cout<<"ProB Done"<<endl;
		}
		~ProB() {
			cout <<"ProB.Des"<<endl;
		}
};

int main(void){	
	Factory *pF=new Factory(new ProA);
	pF->Operation();
	delete pF;
	return 0;
}
